﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace FwProject.Migrations.FwProjectAppShopDb
{
    public partial class Reset_ShopOrderCoupon_To_appshop : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "shop_order_coupon",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    OrderNumber = table.Column<string>(nullable: true),
                    OrderId = table.Column<Guid>(nullable: false),
                    UserId = table.Column<long>(nullable: false),
                    ShopCouponId = table.Column<Guid>(nullable: false),
                    ShopUserCouponId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_shop_order_coupon", x => x.Id);
                    table.ForeignKey(
                        name: "FK_shop_order_coupon_shop_order_OrderId",
                        column: x => x.OrderId,
                        principalTable: "shop_order",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_shop_order_coupon_shop_coupon_ShopCouponId",
                        column: x => x.ShopCouponId,
                        principalTable: "shop_coupon",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_shop_order_coupon_OrderId",
                table: "shop_order_coupon",
                column: "OrderId");

            migrationBuilder.CreateIndex(
                name: "IX_shop_order_coupon_ShopCouponId",
                table: "shop_order_coupon",
                column: "ShopCouponId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "shop_order_coupon");
        }
    }
}
